package com.zqxq.lottery.controller.order;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.lottery.config.YmlConfig;
import com.zqxq.lottery.entity.bo.order.TradeInfoBO;
import com.zqxq.lottery.entity.o2o.order.TradeInfoO2O;
import com.zqxq.lottery.entity.po.order.TradeInfoPO;
import com.zqxq.lottery.service.order.ITradeInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/26 09:59
 */
@RestController
@Slf4j
@RequestMapping("/tradeInfo")
public class TradeInfoController {

    @Autowired
    private ITradeInfoService tradeInfoService;
    @Autowired
    private YmlConfig ymlConfig;

    //分页查询列表
    @PostMapping("/insert")
    public Result insert(@RequestBody TradeInfoBO bo){
        Result rs = new Result();
        try{
            if(bo == null || bo.getUserId() == null){
                rs.setCode(CodeEnum.FAIL_100002.getCode());
                rs.setMsg(CodeEnum.FAIL_100002.getMsg());
            }
            TradeInfoPO po = TradeInfoO2O.toPO(bo);
            po.setId(ymlConfig.getPkId());
            tradeInfoService.insert(po);
        }catch(Exception e){
            rs.setCode(CodeEnum.FAIL_100005.getCode());
            rs.setMsg(CodeEnum.FAIL_100005.getMsg());
            log.error("UerOrder Page  Error:",e);
        }
        return rs;
    }

}
